import React from 'react';
import {BrowserRouter, Route, withRouter} from 'react-router-dom';

function A(props) {
    console.log(props.match);
    return (
        <>
            <h1>组件A</h1>
            <button onClick={() => {
                props.history.push('/b')
            }}>调转到B
            </button>
        </>
    )
}

function B(props) {
    console.log(props.match);
    return (
        <>
            <h1>组件B</h1>
            <button onClick={() => {
                props.history.push('a/尼玛/20')
            }}>调转到A
            </button>
        </>
    )
}

const C_ss = withRouter(C_s)
function C(props) {
    return (
        <div>回到首页
            <C_ss/>
        </div>
    )
}
function C_s(props) {
    return (
        <button onClick={() => {
            props.history.push('/')
        }
        }>
        </button>
    )
}
function RouterInfo(props) {
    return (
        <BrowserRouter>
            <Route path="/a/:year(\d+)?/:month?/:day" component={A} exact={true}/>
            <Route path="/b" component={B} sensitive={true}/>
        </BrowserRouter>
    );
}

export default RouterInfo;